Parse and stringify YAML code blocks in remark.
Supports IE9+ (mdn, Kangax).
Installation
npm
npm install remark-yaml
remark-yaml is also available for duo,
and as an AMD, CommonJS, and globals module, uncompressed and
compressed.
Table of Contents
Usage
var yaml = require('remark-yaml');
var remark = require('remark').use(yaml);
var input = [
'---',
'"layout": "post"',
'"title": \'Blogging Like a Hacker\'',
'---',
'',
'# A header!',
''
].join('\n');
var tree = remark.parse(input);
The yaml
node now has a yaml
property.
var data = tree.children[0].yaml;
{
"layout": "post",
"title": "Blogging Like a Hacker"
}
Stringifying the document (note the formatting) yields:
var doc = remark.stringify(tree);
---
layout: post
title: Blogging Like a Hacker
---
# A header!
API
Adds a yaml
property to YAML nodes.
Signatures
remark = remark.use(yaml, options?)
.
Parameters
License
MIT © Titus Wormer